//app.js
//Page Object
import { request } from '../../request/index.js'

Page({
  data: {
    // 轮播图数组
    swiperlist: [],
    // 导航数组
    catelist: [],
    // 楼层数组
    floorlist: [],
    // 楼层列跳转类型
    goodsType: ""
  },
  //options(Object)
  onLoad: function (options) {
    this.getSwiperList()
    this.getCateList()
    this.getFloorList()
  },
  getSwiperList() {
    request({
      url: '/home/swiperdata'
    })
      .then(res => {
        this.setData({
          swiperlist: res
        })
      })
      .catch(err => {
        console.log(err)
      })
  },
  getCateList() {
    request({
      url: '/home/catitems'
    })
      .then(res => {
        this.setData({
          catelist: res
        })
      })
      .catch(err => {
        console.log(err)
      })
  },
  getFloorList() {
    request({
      url: '/home/floordata'
    })
      .then(res => {
        this.setData({
          floorlist: res
        })
      })
      .catch(err => {
        console.log(err)
      })
  },
  handelNav(e) {
    const { index } = e.currentTarget.dataset
    console.log(index)
    if (index === 0) {
      this.setData({
        goodsType: "户外"
      })
    } else if (index === 1) {
      this.setData({
        goodsType: "热"
      })
    } else {
      this.setData({
        goodsType: "饰品"
      })
    }
  }
});